package com.yanqu.road.server.cross3server.cmd.xrank;

import com.yanqu.road.logic.pb.XRankPb;
import com.yanqu.road.entity.rank.xrank.XUserRank;
import com.yanqu.road.logic.xlogic.rank.user.entiety.XUserRankChangeParam;
import com.yanqu.road.pb.cross3.activity.XRankProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.cross3server.manager.Cross3XRankMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Cross3Protocol;

import java.util.List;

@Cmd(code = Cross3Protocol.C3_XRANK_SYNC_USER_RANK_FROM_CHANNEL, desc = "跨区域服 同步个人榜")
public class XRankSyncUserRankFromChannelCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        XRankProto.XUserRankListMsg reqMsg = XRankProto.XUserRankListMsg.parseFrom(packet.getBytes());
        int activityId = reqMsg.getActivityId();
        int conditionType = reqMsg.getConditionType();
        List<XRankProto.XUserRankMsg> rankMsgList = reqMsg.getRankListList();
        for (XRankProto.XUserRankMsg rankMsg : rankMsgList) {
            XUserRank userRank = XRankPb.parseXUserRank(activityId, conditionType, rankMsg);
            Cross3XRankMgr.getUserRankMap().userRankChange(userRank, new XUserRankChangeParam(false, true, rankMsg.getBaseInfo()));
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
